
export enum LoggerLevel {
    Debug,
    Info,
    Warn,
    Error,
    Silent,
}

const _loggerSetting = {
    Level: LoggerLevel.Debug,
}

export const LoggerSetting: Readonly<typeof _loggerSetting> = _loggerSetting;

const origin_debug = console.debug;
const origin_log = console.log;
const origin_warn = console.warn;
const origin_error = console.error;

console.debug = function (...args: any[]) {
    if (_loggerSetting.Level <= LoggerLevel.Debug) {
        origin_debug.apply(console, args);
    }
}

console.log = function (...args: any[]) {
    if (_loggerSetting.Level <= LoggerLevel.Info) {
        origin_log.apply(console, args);
    }
}

console.warn = function (...args: any[]) {
    if (_loggerSetting.Level <= LoggerLevel.Warn) {
        origin_warn.apply(console, args);
    }
}

console.error = function (...args: any[]) {
    if (_loggerSetting.Level <= LoggerLevel.Error) {
        origin_error.apply(console, args);
    }
}

export function SetLoggerLevel(level: LoggerLevel) {
    _loggerSetting.Level = level;
}
